package cn.iocoder.yudao.module.product.spu.vo;

import cn.iocoder.yudao.framework.validation.InEnumValue;
import cn.iocoder.yudao.framework.validation.groups.UpdateGroup;
import cn.iocoder.yudao.module.api.dine.enums.DineAttributeEnum;
import cn.iocoder.yudao.module.api.product.spu.enums.ProductPriceModeEnum;
import cn.iocoder.yudao.module.api.product.spu.enums.ProductSpuRecommendEnum;
import cn.iocoder.yudao.module.product.sku.vo.ProductSkuSaveReqVO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.List;

@Schema(description = "管理后台 - 产品 SPU 新增/更新 Request VO")
@Data
public class ProductSpuSaveReqVO {

    @Schema(description = "产品编号", example = "1")
    @NotNull(message = "产品编号不能为空", groups = {UpdateGroup.class})
    private Long id;

    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖清丝滑不出汗")
    @NotEmpty(message = "产品名称不能为空")
    private String name;

    @Schema(description = "关键字", example = "小短袖,丝滑，清凉")
    private String keyword;

    @Schema(description = "产品简介", example = "清凉小短袖简介，清凉小短袖简介，清凉小短袖简介")
    private String introduction;

    @Schema(description = "产品详情", example = "清凉小短袖详情")
    private String description;

    @Schema(description = "行业类目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long platformCategoryId;

    @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "产品分类不能为空")
    private Long categoryId;

    @Schema(description = "产品品牌编号", example = "0")
    private Long brandId;

    @Schema(description = "产品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.example.com/xx.png")
    @NotEmpty(message = "产品封面图不能为空")
    private String picUrl;

    @Schema(description = "产品轮播图")
    @Size(max = 9, message = "产品轮播图不能超过 9 张")
    private List<String> sliderPicUrls;

    @Schema(description = "单位名称")
    private String unitName;

    @Schema(description = "条形码", example = "202404051353520")
    private String barCode;

    // ========== SKU 相关字段 =========

    @Schema(description = "规格类型：0-单规格、1-多规格", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    @NotNull(message = "产品 SKU类型不能为空")
    private Boolean specType;

    @Schema(description = "计价模式：1-按单品计价、2-按称量计价")
    @InEnumValue(ProductPriceModeEnum.class)
    private Integer priceMode;

    // ========== 物流相关字段 =========

    @Schema(description = "配送类型/服务方式数组：0-无、1-快递发货、2-到店自提、3-同城配送、4-现场核销、5-上门服务", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotEmpty(message = "配送类型/服务方式不能为空")
    private List<Integer> deliveryTypes;

    @Schema(description = "物流配置模板编号，快递发货时需要", example = "0")
    private Long deliveryTemplateId;

    // ========== 营销相关字段 =========

    @Schema(description = "推荐类型：0-无、1-精选、2-爆款、3-新品、4-补贴", example = "0")
    @InEnumValue(ProductSpuRecommendEnum.class)
    private Integer recommend;

    @Schema(description = "是否置顶", example = "false")
    private Boolean isSticky;

    @Schema(description = "是否积分产品", example = "false")
    private Boolean isIntegral;

    @Schema(description = "起购数量/起批数量", example = "1")
    private Integer limitMinQuantity;

    @Schema(description = "限购数量", example = "999")
    private Integer limitMaxQuantity;

    @Schema(description = "每次加购数量", example = "1")
    private Integer stepQuantity;

    // ========== 统计相关字段 =========

    @Schema(description = "虚拟销量", example = "66")
    private Integer virtualSalesCount;

    @Schema(description = "产品销量", example = "1999")
    private Integer salesCount;

    @Schema(description = "浏览量", example = "1999")
    private Integer browseCount;

    // ========== SKU 相关字段 =========

    @Schema(description = "SKU 数组")
    @Valid
    private List<ProductSkuSaveReqVO> skus;

    @Schema(description = "购买须知", example = """
            {"after_sale": "未拆封、不影响二次销售的情况下，支持7天无理由，邮费自理。质量问题请提供面单和内容物照片。", "delivery_time": "48小时(周末、节假日延后)", "special_version": "无运费险!订单已发货状态即表示已打包，非我方原因要拒收或拦载退款，可能需扣除运费相应的发货运费。", "delivery_expressage": "普通快递随机"}
            """)
    private String guidance;

    @Schema(description = "标签，英文逗号分隔")
    private List<String> labels;

    @Schema(description = "菜肴属性：0-无、1-主食、2-荤菜、3-素菜、4-汤、5-调料、6-饮品、7-水果、20-锅底、50-套餐、98-餐盒、99-备注")
    @InEnumValue(DineAttributeEnum.class)
    private Integer dishAttribute;

}
